/**
*	IE8��һ��֧��Map����
*/
function Map() {  
     this.elements = new Array();  
     // ��ȡMapԪ�ظ���  
     this.size = function() {  
         return this.elements.length;  
     },  
     // �ж�Map�Ƿ�Ϊ��  
     this.isEmpty = function() {  
         return (this.elements.length < 1);  
     },  
     // ɾ��Map����Ԫ��  
     this.clear = function() {  
         this.elements = new Array();  
     },  
     // ��Map������Ԫ�أ�key, value)  
     this.put = function(_key, _value) {  
         if (this.containsKey(_key) == true) {  
             if (this.containsValue(_value)) {  
                 if (this.remove(_key) == true) {  
                     this.elements.push({  
                         key : _key,  
                         value : _value  
                     });  
                 }  
             } else {  
                 this.elements.push({  
                     key : _key,  
                     value : _value  
                 });  
             }  
         } else {  
             this.elements.push({  
                 key : _key,  
                 value : _value  
             });  
         }  
     },  
     // ��Map������Ԫ�أ�key, value)  
     this.set = function(_key, _value) {  
         if (this.containsKey(_key) == true) {  
             if (this.containsValue(_value)) {  
                 if (this.remove(_key) == true) {  
                     this.elements.push({  
                         key : _key,  
                         value : _value  
                     });  
                 }  
             } else {  
                 this.elements.push({  
                     key : _key,  
                     value : _value  
                 });  
             }  
         } else {  
             this.elements.push({  
                 key : _key,  
                 value : _value  
             });  
         }  
     },  
     // ɾ��ָ��key��Ԫ�أ��ɹ�����true��ʧ�ܷ���false  
     this.remove = function(_key) {  
         var bln = false;  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].key == _key) {  
                     this.elements.splice(i, 1);  
                     return true;  
                 }  
             }  
         } catch (e) {  
             bln = false;  
         }  
         return bln;  
     },  

     // ��ȡָ��key��Ԫ��ֵvalue��ʧ�ܷ���null  
     this.get = function(_key) {  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].key == _key) {  
                     return this.elements[i].value;  
                 }  
             }  
         } catch (e) {  
             return null;  
         }  
     },  

     // setָ��key��Ԫ��ֵvalue  
     this.setValue = function(_key, _value) {  
         var bln = false;  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].key == _key) {  
                     this.elements[i].value = _value;  
                     return true;  
                 }  
             }  
         } catch (e) {  
             bln = false;  
         }  
         return bln;  
     },  

     // ��ȡָ��������Ԫ�أ�ʹ��element.key��element.value��ȡkey��value����ʧ�ܷ���null  
     this.element = function(_index) {  
         if (_index < 0 || _index >= this.elements.length) {  
             return null;  
         }  
         return this.elements[_index];  
     },  

     // �ж�Map���Ƿ���ָ��key��Ԫ��  
     this.containsKey = function(_key) {  
         var bln = false;  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].key == _key) {  
                     bln = true;  
                 }  
             }  
         } catch (e) {  
             bln = false;  
         }  
         return bln;  
     },  

     // �ж�Map���Ƿ���ָ��key��Ԫ��  
     this.has = function(_key) {  
         var bln = false;  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].key == _key) {  
                     bln = true;  
                 }  
             }  
         } catch (e) {  
             bln = false;  
         }  
         return bln;  
     },  
       
     // �ж�Map���Ƿ���ָ��value��Ԫ��  
     this.containsValue = function(_value) {  
         var bln = false;  
         try {  
             for (i = 0; i < this.elements.length; i++) {  
                 if (this.elements[i].value == _value) {  
                     bln = true;  
                 }  
             }  
         } catch (e) {  
             bln = false;  
         }  
         return bln;  
     },  

     // ��ȡMap������key�����飨array��  
     this.keys = function() {  
         var arr = new Array();  
         for (i = 0; i < this.elements.length; i++) {  
             arr.push(this.elements[i].key);  
         }  
         return arr;  
     },  

     // ��ȡMap������value�����飨array��  
     this.values = function() {  
         var arr = new Array();  
         for (i = 0; i < this.elements.length; i++) {  
             arr.push(this.elements[i].value);  
         }  
         return arr;  
     };  
       
     /** 
     * map�������� 
     * @param callback [function(key��value)] �ص������� 
     */  
     this.forEach = function forEach(callback){  
         // �ص�����
         if (typeof callback === 'function') {
        	 for(var i = 0; i < this.elements.length;i++) {  
        	 	callback(this.elements[i].key,this.elements[i].value);
             }
         }
     }  

 }

/**
*	����֧��remove����
*/
Array.prototype.remove = function(val) {
	var index = this.indexOf(val);
	if (index > -1) {
		this.splice(index, 1);
	}
};

/**
*	����Backspace
*/
$(document).keydown(function(e){
	var target = e.target ;
    var tag = e.target.tagName.toUpperCase();
    if(e.keyCode == 8){
		if((tag == 'INPUT' && !$(target).attr("readonly"))||(tag == 'TEXTAREA' && !$(target).attr("readonly"))){
			if((target.type.toUpperCase() == "RADIO") || (target.type.toUpperCase() == "CHECKBOX")){
				return false ;
			}else{
				return true ; 
			}
		}else{
			return false ;
		}
    }
});  

/**
 * 1/2176782336重复率
 */
var CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');   
Math.uuid = function (len, radix) {   
  var chars = CHARS, uuid = [], i;   
  radix = radix || chars.length;   
  if (len) {   
    for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random()*radix];   
  } else {   
    var r;   
    uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';   
    uuid[14] = '4';   
    for (i = 0; i < 36; i++) {   
      if (!uuid[i]) {   
        r = 0 | Math.random()*16;   
        uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];   
      }   
    }   
  }   
  return uuid.join('');   
};
Math.uuid32 = function () {
	var reg1 = new RegExp("-", "g");
	return Math.uuid().replace(reg1, "").toLowerCase();
};
